<template>
  <div class="drug">
    <div class="dl-img">
      <el-image :src="props.drug.outerPackagePicUrl" fit="contain" />
    </div>
    <div class="dl-txt">
      <div class="dl-row">
        <div class="dl-col dl-col1">名称：</div>
        <div class="dl-col">{{ drugName }})</div>
      </div>
      <div class="dl-row">
        <div class="dl-col dl-col1">规格：</div>
        <div class="dl-col">
          {{ props.drug.standard }}
        </div>
      </div>
      <div class="dl-row">
        <div class="dl-col dl-col1">生产厂家：</div>
        <div class="dl-col">
          {{ props.drug.producerName }}
        </div>
      </div>
      <div class="dl-row">
        <div class="dl-col dl-col1">批号：</div>
        <div class="dl-col">
          {{ props.drug.drugId }}
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { computed } from "vue";
const props = defineProps({
  drug: {
    type: Object,
    required: true
  }
});

const drugName = computed(() => {
  if (props.drug.productName) {
    return `${props.drug.commonName}(${props.drug.productName})`;
  } else {
    return props.drug.commonName;
  }
});
</script>
<style lang="scss">
.drug {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: #eee;
  padding: 10px;
  box-sizing: border-box;
  border-radius: 8px;
  margin-bottom: 20px;
  flex-shrink: 0;
  .dl-img {
    width: 80px;
    .el-image {
      width: 80px;
      height: 80px;
    }
  }
  .dl-txt {
    margin-left: 20px;
    .dl-row {
      margin-bottom: 10px;
      display: flex;
      align-items: center;
      justify-content: flex-start;
    }
  }
}
</style>
